package com.cloudfun.msglisten.ws.haier.handler;

import com.cloudfun.msglisten.common.model.haier.HaierWsAckRespDTO;
import com.cloudfun.msglisten.ws.haier.HaierWsClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * Created by Huqin on 2019/12/17
 */
@Slf4j
@Component
public class HaierWsSubAckMsgHandler implements HaierWsCmdAckMsgHandler {

    @Override
    public String command() {
        return "subscribe-ack";
    }

    @Override
    public void handleAck(HaierWsAckRespDTO ackRespDTO, HaierWsClient haierWsClient) {
        log.debug("收到海尔websocket订阅应答信息：{}", ackRespDTO);
        if ("00000".equals(ackRespDTO.getCode())) {
            haierWsClient.updateSubScribeResult(true);
            log.debug("收到海尔websocket订阅应答信息，订阅成功:{}", ackRespDTO.getDesc());
        } else {
            haierWsClient.updateSubScribeResult(false);
            log.debug("收到海尔websocket订阅应答信息，订阅失败:{}", ackRespDTO.getDesc());
        }
    }
}
